<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all"/>
    <link rel="stylesheet" href="{:_SKIN}/shadmin/v3//css/news.css" media="all"/>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote mylog-info-tit">
    <div class="layui-inline">
        <form class="layui-form" id="roleSearchForm">
            <div class="layui-input-inline" style="width:110px;">
                <select name="searchTerm" id="state">

                    {notempty name="state"}


                    {switch name="state"}
                    {case value="1"}
                    <option value="{$state}">未审核</option>
                    {/case}

                    {case value="2"}
                    <option value="{$state}">未通过</option>
                    {/case}


                    {case value="3"}
                    <option value="{$state}">已上架</option>
                    {/case}


                    {case value="4"}
                    <option value="{$state}">已下架</option>
                    {/case}


                    {/switch}







                    {/notempty}
                    <option value="0">全部</option>
                    <option value="1">未审核</option>
                    <option value="2">已拒绝</option>
                    <option value="3">已上架</option>
                    <option value="4">已下架</option>
                </select>

            </div>
            <div class="layui-input-inline" style="width:180px;">
                <input type="text" name="searchContent" id="key" value="" placeholder="请输入商品或商家名称" class="layui-input search_input">
            </div>
            <a class="layui-btn layui-btn-normal  roleAdd_btn" id="so"> <i class="layui-icon larry-icon larry-xinzeng1"></i>查询商品</a>
        </form>
    </div>

    <div class="layui-inline">
        <a class="layui-btn layui-btn-danger  roleAdd_btn" onclick="alert('未开启批量删除功能')"> <i class="layui-icon larry-icon "></i>批量删除</a>
    </div>


    <div class="layui-inline">
        <a class="layui-btn layui-btn-normal excelRoleExport_btn" style="background-color:#5FB878"> <i
                class="layui-icon larry-icon larry-danye"></i>导出</a>
    </div>

    <div class="layui-inline">
        <div class="layui-form-mid layui-word-aux">　共找到 {$num} 个商品</div>
    </div>


</blockquote>

<div class="layui-form news_list">
    <table class="layui-table">
        <colgroup>
            <col width="50">
            <col>
            <col width="9%">
            <col width="5%">
            <col width="5%">
            <col width="9%">
            <col width="6%">
            <col width="15%">
        </colgroup>
        <thead>
        <tr>
            <th></th>
            <th style="text-align:left;">商品名称</th>
            <th>商品分类</th>
            <th>价格</th>
            <th>单位</th>
            <th>卖家</th>
            <th>商品状态</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="news_content">
        {volist name="list" id="v"}
        <tr>
            <td><input type="checkbox" name="checked" lay-skin="primary" lay-filter="choose">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
            </td>
            <td align="left" class=" v_product "  data-url="{:url('product',['id'=>$v['ID']])}"><a  class="layui-icon" >&#xe615;</a> {$v.Name}</td>
            <td>{$v.ProductCategory}</td>
            <td>￥{$v.Price}</td>
            <td>{$v.type}</td>

            <td>{$v.Business} <a href="{:Url('sproductlist',['bid'=>$v['BusinessID']])}" class="layui-icon">&#xe615;</a>
            </td>


            {eq name="v.ISSells" value="1"}
            <td><input type="checkbox" name="show" lay-skin="switch" lay-text="上架|下架" lay-filter="isShow"
                       data-id="{$v.ID}" checked=""></td>
            {else /}
            <td><input type="checkbox" name="show" lay-skin="switch" lay-text="上架|下架" lay-filter="isShow"
                       data-id="{$v.ID}"></td>
            {/eq}


            <td>{$v.CreateTime}</td>
            <td><a class="layui-btn layui-btn-mini news_edit">推荐</a>

                {eq name="v.ISSells" value="1"}

                <a class="layui-btn layui-btn-normal layui-btn-mini news_collect pro_sells v_product" data-url="{:url('product',['id'=>$v['ID']])}">审核</a>

                {else /}

                <a class="layui-btn layui-btn-normal layui-btn-mini news_collect pro_sells" data-id="{$v.ID}">上架</a>


                {/eq}


                <a class="layui-btn layui-btn-danger layui-btn-mini pro_del" data-id="{$v.ID}">删除</a>


            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>

<div id="page">{$page}</div>
{:jq()}
{:layui()}
<style>
    .pagination {
        margin-left: 50px;
    }

    .pagination li {
        float: left;
        background: #34a8fe;
        color: #fff;
        margin-right: 8px;
    }

    .pagination li a, .pagination li span {
        color: #fff;
        padding: 8px 10px;
        display: block
    }

    .pagination .active {
        background-color: #fe6738
    }

</style>
<script>

    //检索产品

    $("#so").click(function(){

        var data={
            state:$("#state").val(),
            key:$("#key").val()

        }


        location.href="{:url('sproductlist')}/state/"+data.state+"/key/"+data.key;

        /* $.post("{:url('productlist')}",data,function(res){

              location.href=res.url;


         });

         */





    });


    //删除商品
    $(".pro_del").click(function () {
        var id = $(this).data('id');
        parent.layer.confirm("确定要删除该商品吗？删除后不可恢复", function () {

            $.post("{:url('dev/delpro')}", {id: id}, function (res) {

                if (res.code == 200) {


                    parent.layer.msg('删除成功', {shift: 0, time: 2000}, function () {

                        location.reload();
                    });

                } else {

                    parent.layer.msg(res.msg);

                }

            });


        });


    });



    //修改产品状态
    layui.form.on('switch(isShow)', function (data) {
        var id = $(data.elem).data('id');


        var key = data.elem.checked ? 1 : 0;

        $.post("{:url('dev/sells')}", {id: id, key: key}, function (res) {

            if (res.code != 200) {

                panent.layer.alert('网络繁忙，请重试');

            }

        });


    });

    //预览产品

    $(".v_product").click(function(){

        var url=$(this).data('url');

        layer.open({
            type: 2,
            title: '商品预览',
            shadeClose: true,
            shade: 0.8,
            area: ['380px', '90%'],
            content: url //iframe的url
        });



    });

</script>
</body>
</html>